#!/bin/ksh
#
# Written by: Chuck Spilman			10/25/2002
#
# Description:
#   list information about lv's: what disks lv resides on, what slot the disks are in 
#   the SSA enclosure, how many copies of the lv there are and what hdisk's and pdisks 
#   they are on.
#

lvname=""
vgname=""

while getopts l:v: option
do
  case ${option} in
	l) lvname="${OPTARG}";;
	v) vgname="${OPTARG}";;
  esac
done

if [ "${vgname}" != "" ]
then
  vglist="${vgname}"
else
  vglist=$(lsvg -o | egrep "esnvg|dbvg")
fi

if [ "${lvname}" != "" ]
then
  lvlist="${lvname}"
else
  lvlist=$(lsvg -l ${vglist} | egrep -v "${vglist}|LV" | awk '{print $1}')
fi

for vg in ${vglist}
do
  echo "${vg}:" ; echo
# for lv in `lsvg -l ${vg} | egrep -v "${vg}|LV" | awk '{print $1}'`
  for lv in ${lvlist}
  do
    for hdisk in `lslv -l ${lv} | egrep -v "PV|${lv}" | awk '{print $1}'`
    do
      pdisk=`ssaxlate -l ${hdisk}`
      slot=`lsdev -Cc pdisk | grep ${pdisk} | awk -F"-" '{print "["$3"-"$4"]"}' | head -1`
      size=`lsattr -El ${pdisk} | grep size_in_mb | awk '{print $2}'`
      echo "${lv}:	${hdisk}	${pdisk}	${slot}	${size}"
    done
  echo
  done
done
